package com.qixin.modules.eaStandard.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qixin.modules.eaStandard.entity.EaRelationSetting;
import com.qixin.modules.eaStandard.mapper.EaRelationSettingMapper;
import com.qixin.modules.eaStandard.service.IEaRelationSettingService;
import com.qixin.modules.eaStandard.vo.EaRelationTypeVo;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.util.EmptyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: ea_relation_setting
 * @Author: qixin-boot
 * @Date:   2021-11-19
 * @Version: V1.0
 */
@Service
public class EaRelationSettingServiceImpl extends ServiceImpl<EaRelationSettingMapper, EaRelationSetting> implements IEaRelationSettingService {
    @Autowired
    private EaRelationSettingMapper eaRelationSettingMapper;

    @Override
    public List<DictModel> queryRelationSettingByType(EaRelationTypeVo eaRelationTypeVo) {
        Map<String,Object> map = new HashMap<String,Object>();
        String serviceType = EmptyUtil.checkNull(eaRelationTypeVo.getServiceType());    //业务类型：消费类型(1,2,3,4,5,6)，单据类型(1,2,3,4,5,6)
        String relatedType = EmptyUtil.checkNull(eaRelationTypeVo.getRelatedType());    //关联设置类型：消费类型1，单据类型2

        if(!serviceType.equals("")){
            String[] serviceTypes = serviceType.split(",");
            map.put("serviceType",serviceTypes);
        }else{
            map.put("serviceType",serviceType);
        }
        map.put("relatedType",relatedType);

        List<DictModel> dictModels = eaRelationSettingMapper.queryRelationSettingByType(map);
        return dictModels;
    }
}
